<?php
namespace app\home\controller;
use app\common\controller\Homebase;
use \think\Db;
use \think\Request;

// +----------------------------------------------------------------------
// | XpCms
// +----------------------------------------------------------------------
// | Copyright (c) 2021-2099
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Mercurio（Xp） <725668993@qq.com>
// +----------------------------------------------------------------------

/*
** 前台首页
*/

class Index extends Homebase {
    private static $_options 	= null; // 数据表对象
	
	// 优先加载
	public function  _initialize() {
		parent::_initialize();
		// 实例化数据表模型
		self::$_options = Db::name('Options');
		$request = Request::instance();
		//当前模块
		$this->module = strtolower($request->module());
		
	}
	
	public function index1() {
	    $content = $this->fetch(); 
	    $content = qss5ucms($content); //模板标签转换
		return $this->display($content);
// 		return view('index');
	}
	
	//首页
    public function index()
    {
        //测试插件
        //hook('test', ['id'=>2]);
        $content = self::$_options -> where(array('title' => 'siteinfo')) -> value('content');
		$site = json_decode($content, true);
        //后台开启手机端的时候自动跳转
        // if($system['mobile']=='1'){
        //     if(isMobile()){
        //         $this->redirect('mobile/index/index');
        //     }
        // }
        $this->view->assign('cate', null);//
        $this->view->assign('site', $site);//系统信息
        $this->view->assign('title', $site['seo_title']);//seo信息
        $this->view->assign('keywords', $site['seo_keys']);//seo信息
        $this->view->assign('description', $site['seo_desc']);//seo信息
        $template='./tpl/'.$this->module.'/'.$site['template'].'/index.html';
        return $this->view->fetch($template);
    }
	
}
